package com.fable.sp.core.repository;

import com.fable.sp.core.domain.Container;
import com.fable.sp.core.domain.ContainerQuery;
import com.slyak.spring.jpa.GenericJpaRepository;
import com.slyak.spring.jpa.TemplateQuery;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

/**
 * .
 *
 * @author stormning on 16/8/1.
 */
public interface ContainerRepository extends GenericJpaRepository<Container, Long> {

    @Override
    @CacheEvict(cacheManager = "spCacheManager", value = "c_findOne", key = "#p0.id")
    <S extends Container> S save(S entity);

    @Override
    @Cacheable(cacheManager = "spCacheManager", value = "c_findOne", key = "#p0")
    Container findOne(Long id);

    @TemplateQuery
    Page<Container> queryContainers(ContainerQuery query, Pageable pageable);
}
